package com.ruoyi.web.xxj.contoller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.xxj.domain.PaymentInfo;
import com.ruoyi.web.xxj.domain.vo.PaymentInfoVo;
import com.ruoyi.web.xxj.service.IPaymentInfoService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支付流水Controller
 *
 * @author ruoyi
 * @date 2024-01-27
 */
@Api(tags = "支付流水管理")
@RestController
@RequestMapping("/xxj/paymentInfo")
public class PaymentInfoController extends BaseController {
    @Autowired
    private IPaymentInfoService paymentInfoService;

    /**
     * 查询支付流水列表
     */
    @ApiOperation("查询支付流水列表")
    @GetMapping("/list")
    public TableDataInfo<PaymentInfoVo> list(PaymentInfo paymentInfo) {
        startPage();
        List<PaymentInfoVo> list = paymentInfoService.selectPaymentInfoList(paymentInfo);
        return getDataTable(list);
    }

    /**
     * 导出支付流水列表
     */
    @ApiOperation("导出支付流水列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaymentInfo paymentInfo) {
        List<PaymentInfoVo> list = paymentInfoService.selectPaymentInfoList(paymentInfo);
        ExcelUtil<PaymentInfoVo> util = new ExcelUtil<PaymentInfoVo>(PaymentInfoVo.class);
        util.exportExcel(response, list, "支付流水数据");
    }

    /**
     * 获取支付流水详细信息
     */
    @ApiOperation("获取支付流水详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(paymentInfoService.selectPaymentInfoById(id));
    }

    /**
     * 新增支付流水
     */
    @ApiOperation("新增支付流水")
    @PostMapping
    public AjaxResult add(@RequestBody PaymentInfo paymentInfo) {
        return toAjax(paymentInfoService.insertPaymentInfo(paymentInfo));
    }

    /**
     * 修改支付流水
     */
    @ApiOperation("修改支付流水")
    @PutMapping
    public AjaxResult edit(@RequestBody PaymentInfo paymentInfo) {
        return toAjax(paymentInfoService.updatePaymentInfo(paymentInfo));
    }

    /**
     * 删除支付流水
     */
    @ApiOperation("删除支付流水")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(paymentInfoService.deletePaymentInfoByIds(ids));
    }

}
